import { minimizeWindow, toggleAlwaysOnTop, toggleFullScreen } from '../actions/window'
import { zoomIn, zoomOut } from '../../windows/utils'
import { COMMANDS } from '../../commands'

export default function (keybindings, language) {
  return {
    label: language.getString('window'),
    submenu: [{
      label: language.getString('minimize'),
      accelerator: keybindings.getAccelerator(COMMANDS.WINDOW_MINIMIZE),
      click (menuItem, browserWindow) {
        minimizeWindow(browserWindow)
      }
    }, {
      id: 'alwaysOnTopMenuItem',
      label: language.getString('alwaysOnTop'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.WINDOW_TOGGLE_ALWAYS_ON_TOP),
      click (menuItem, browserWindow) {
        toggleAlwaysOnTop(browserWindow)
      }
    }, {
      type: 'separator'
    }, {
      label: language.getString('zoomIn'),
      accelerator: keybindings.getAccelerator(COMMANDS.WINDOW_ZOOM_IN),
      click (menuItem, browserWindow) {
        zoomIn(browserWindow)
      }
    }, {
      label: language.getString('zoomOut'),
      accelerator: keybindings.getAccelerator(COMMANDS.WINDOW_ZOOM_OUT),
      click (menuItem, browserWindow) {
        zoomOut(browserWindow)
      }
    }, {
      type: 'separator'
    }, {
      label: language.getString('showInFullScreen'),
      accelerator: keybindings.getAccelerator(COMMANDS.WINDOW_TOGGLE_FULL_SCREEN),
      click (item, browserWindow) {
        if (browserWindow) {
          toggleFullScreen(browserWindow)
        }
      }
    },{
      type: 'separator'
    },{
      id: 'menuLanguageEn',
      label: 'English',
      type: 'radio',
      checked: language.getCurrentLanguage() === 'en',
      click (menuItem, browserWindow) {
        language.setLanguage('en')
      }
    }, {
      id: 'menuLanguageZh',
      label: '中文',
      type: 'radio',
      checked: language.getCurrentLanguage() === 'zh',
      click (menuItem, browserWindow) {
        language.setLanguage('zh')
      }
    }]
  }
}
